package echo;

import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;

public class EchoClient {
	public static void main(String[] args) throws Exception, RemoteException {
		if (System.getSecurityManager() == null) {
			System.setSecurityManager(new RMISecurityManager());
		}
		String host = "localhost";
		if (args.length > 0) {
			host = args[0];
		}

		System.out.println("Lookup echo service");
		Echo echostub = (Echo) Naming.lookup("//" + host + "/EchoServer");
		System.out.println("Invoke to echo service");
		//System.out.println(echo.echo("Hello, Echo!"));
		
		//invokerer metoden to gange .....
//		System.out.println("sayingOfToday=" + echostub.echo().sayingOfToday + " count=" + echostub.echo().count );
		
		
		TodaySaying sot;
		sot = (TodaySaying)echostub.echo();
		
		String test =  (String)echostub.echo().sayingOfToday; // sot.getSaying();
		
		//System.out.println("test = " + test);
	}
}
